package gdkm.dao;

import kxc.gdkm.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserDAO {

    @Select("select * from user where id = #{id}")
    User findById(Integer id);
    @Select("select * from user where username = #{username}")
    User findByUsername(String username);

    @Select("select * from user")
    List<User> findAll();

    @Insert("insert into user(username, password, email, phone, user_type, avatar, status, create_time, update_time) values(#{username}, #{password}, #{email}, #{phone}, #{userType}, #{avatar}, #{status}, #{createTime}, #{updateTime})")
    boolean addUser(User user);

    @Update("update user set username = #{username}, password = #{password}, email = #{email}, phone = #{phone}, user_type = #{userType}, avatar = #{avatar}, status = #{status}, update_time = #{updateTime} where id = #{id}")
    boolean updateUser(User user);

    @Delete("delete from user where id = #{id}")
    boolean deleteUser(Integer id);
}

